<?php include(TPL_PATH . '/admin/inc_header.php'); ?>
<?php include(TPL_PATH . '/admin/inc_top.php'); ?>

<script type="text/javascript">
$(document).ready(function() {
	$('input[type=text]').tooltip({'placement':'right'});
	$('select').val('<?php p($arrData['group_name']) ?>');
});

function do_clean(id) {
	if (confirm('删除后不可还原,确定删除吗?')) {
		window.location.href = '<?php p(HTTP_URL) ?>/index.php?m=admin&c=manager&a=clean&id=' + id;
	}
}
</script>

<form action="<?php p(HTTP_URL); ?>/index.php?m=admin&c=manager&a=<?php if ($blnAdd) { ?>add<?php } else { ?>edit&id=<?php p($id); } ?>" method="post">
    <fieldset>
    	<legend>管理员<?php (!$blnAdd) && p(' - ' . $arrData['user_name']) ?></legend>
    	
    	<?php if (!empty($strMsg)) { ?>
		<div class="alert alert-error">
			<button type="button" class="close" data-dismiss="alert">&times;</button>
			<?php p($strMsg) ?>
		</div>
		<?php } elseif (!empty($strOk)) { ?>
    	<div class="alert alert-success">
			<button type="button" class="close" data-dismiss="alert">&times;</button>
			<?php p($strOk) ?>
		</div>
    	<?php } ?>
    	
    	<label for="id_group">用户组</label>
        <select name="group_name" id="id_group" class="input-medium">
        	<?php foreach ($arrGroup as $key => $val) { ?>
        	<option value="<?php p($val['name_en']) ?>"><?php p($val['name']) ?></option>
        	<?php } ?>
        </select>
        <?php if ($blnAdd) { ?>
        <label for="id_name">登录名</label>
        <input type="text" name="user_name" id="id_name" value="<?php p($arrData['user_name']) ?>" title="3~20位由小写字母或数字组成" />
        <?php } ?>
        <label for="id_name_nick">昵称</label>
        <input type="text" name="nick_name" id="id_name_nick" <?php if ($blnAdd) { ?>placeholder="可以留空"<?php } ?> value="<?php p($arrData['nick_name']) ?>" title="3~20位字符组成" />
        <label for="id_password">登录密码</label>
        <input type="text" name="password" id="id_password" <?php if ($blnAdd) { ?>placeholder="abc123"<?php } else { ?>placeholder="留空则不修改"<?php } ?> title="密码由6~20位字母或数字组成" />
        <label for="id_email">Email</label>
        <input type="text" name="email" id="id_email" <?php if ($blnAdd) { ?>placeholder="可以留空"<?php } ?> value="<?php p($arrData['email']) ?>" />
        <label for="id_phone">电话</label>
        <input type="text" name="phone" id="id_phone" <?php if ($blnAdd) { ?>placeholder="可以留空"<?php } ?> value="<?php p($arrData['phone']) ?>" />
        <?php if (!$blnAdd) { ?>
        <label class="checkbox">
            <input name="rec_status" type="checkbox" <?php if ($arrData['rec_status']) { ?>checked="checked"<?php } ?> value="1" /> 可用状态
        </label>
        <?php } ?>
        <br />
        <input type="submit" class="btn btn-primary" name="sub_btn" value="保存修改" />
        <?php if (!$blnAdd) { ?>
        <a class="btn btn-danger" href="javascript:do_clean(<?php p($id) ?>);">删除</a>
        <?php } ?>
        <a href="<?php p(HTTP_URL) ?>/index.php?m=admin&c=manager" class="btn">返回列表</a>
    </fieldset>
</form>

<?php include(TPL_PATH . '/admin/inc_bottom.php'); ?>
<?php include(TPL_PATH . '/admin/inc_footer.php'); ?>